import Cookies from 'js-cookie'

const TokenKey = 'Admin-Token'
const UserIdKey = 'User-Id'

export function getToken() {
  return Cookies.get(TokenKey)
}

export function setToken(token) {
  return Cookies.set(TokenKey, token)
}

export function removeToken() {
  return Cookies.remove(TokenKey)
}

export function getUserId() {
  const userId = Cookies.get(UserIdKey) || localStorage.getItem(UserIdKey)
  return userId ? parseInt(userId) : 1 // 默认返回ID为1的用户ID
}

export function setUserId(id) {
  Cookies.set(UserIdKey, id)
  localStorage.setItem(UserIdKey, id)
  return id
}

export function removeUserId() {
  Cookies.remove(UserIdKey)
  localStorage.removeItem(UserIdKey)
}
